package cc.eddic.pratice.programmingparadigms;


import cc.eddic.pratice.programmingparadigms.emp01array.impl.StatisticsGcsImpl;
import cc.eddic.pratice.programmingparadigms.emp02list.ResultList;
import cc.eddic.pratice.programmingparadigms.emp02list.impl.ResultListGcsImpl;

import cc.eddic.pratice.programmingparadigms.emp02list.impl.ResultListTyqImpl;


import cc.eddic.pratice.programmingparadigms.emp02list.impl.ResultListLhImpl;

import cc.eddic.pratice.programmingparadigms.emp02list.impl.ResultListHrjImpl;

import cc.eddic.pratice.programmingparadigms.emp03objlist.ObjectList;
import cc.eddic.pratice.programmingparadigms.emp03objlist.StringList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ProgrammingParadigmsConsoleApplication implements CommandLineRunner {

    private static final Logger log = LoggerFactory.getLogger(ProgrammingParadigmsConsoleApplication.class);

    public static void main(String[] args) {
        SpringApplication.run(ProgrammingParadigmsConsoleApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        StringList sl = new StringList();
        for (int i = 0; i < 3; i++) {
            sl.add(String.valueOf(i));
        }
        log.debug("size {}", sl.size());
        log.debug("#{} = {}", 1, sl.get(1));


//        employeeStat();

//        ResultList resultList = new ResultListGcsImpl(10);
//        ResultList resultList = new ResultListLhImpl(1);
//        resultList.add(new Result("男", 1));
//        resultList.add(new Result("女", 3));
//
//        for (int i = 0; i < resultList.size(); i++) {
//            Result result = resultList.get(i);
//            log.info("{} => {}, {}", i, result.getKey(), result.getCount());
//            System.out.printf("%s   %d\n", result.getKey(), result.getCount());
//        }
//
//        System.out.print(resultList.size());


    }

    private void employeeStat() {
        StatisticsGcsImpl employeeService = new StatisticsGcsImpl();

        Employee[] employees = employeeService.read("");
        printResult(employeeService.pivotByGender(employees));
        printResult(employeeService.pivotByDepartment(employees));
        printResult(employeeService.pivotByJobTitle(employees));
    }

    private void printResult(Result[] results) {
        for (Result result : results) {
            System.out.printf("%35s %3d\n", result.getKey(), result.getCount());
        }
    }
}
